package org.finesys.common.es.pool;

import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import lombok.extern.slf4j.Slf4j;

/**
 * 同步步池化管理
 */
@Slf4j
public class ElasticsearchClientPool extends GenericObjectPool<ElasticsearchClient> {

    // 连接工厂
    private final ElasticsearchClientFactory elasticsearchClientFactory;
    // 连接池配置
    private final GenericObjectPoolConfig<ElasticsearchClient> genericObjectPoolConfig;

    public ElasticsearchClientPool(ElasticsearchClientFactory elasticsearchClientFactory, GenericObjectPoolConfig<ElasticsearchClient> genericObjectPoolConfig) {
        // 初始化对象连接池
        super(elasticsearchClientFactory);
        // 初始化对象连接池
        this.elasticsearchClientFactory = elasticsearchClientFactory;
        this.genericObjectPoolConfig = genericObjectPoolConfig;
    }

    public ElasticsearchClientFactory getElasticsearchClientFactory() {
        return this.elasticsearchClientFactory;
    }


    public GenericObjectPoolConfig<ElasticsearchClient> getGenericObjectPoolConfig() {
        return this.genericObjectPoolConfig;
    }
    
}
